import axios from 'axios';

axios.defaults.baseURL = 'https://localhost:443/api';

window.electron.ipcRenderer.once('user-token', (_event, token) => {
  axios.defaults.headers.common['Authorization'] = token;
  console.log('axios获取的token', token);
  //由于设置Token进浏览器里有延迟，所以需要把重置好友列表的ipc事件延迟
  setTimeout(() => {
    window.electron.ipcRenderer.send('ipc:refresh-friend-list');
  }, 10);
});

window.electron.ipcRenderer.once('user-machineId', (_event, machineId) => {
  axios.defaults.headers.common['X-Device-ID'] = machineId;
  console.log('axios获取的machineId', machineId);
});
